package com.hxt.framework.utils;

import java.util.Random;

public class Tess
{
	public static void main(String[] args)
	{

		for (int i = 0; i < 100; i++)
		{
			System.out.println(getUppercaseAndnum(8));
		}

	}

	// 生成n位随机数(字母大写)
	public static String getUppercaseAndnum2(int length)
	{
		String val = "";
		Random random = new Random();
		for (int i = 0; i < length; i++)
		{
			// 输出字母还是数字
			String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
			// 字符串
			if ("char".equalsIgnoreCase(charOrNum))
			{
				val += (char) (65 + random.nextInt(26));
			} else if ("num".equalsIgnoreCase(charOrNum))
			{ // 数字
				val += String.valueOf(random.nextInt(10));
			}
		}
		return val;
	}

	public static String getUppercaseAndnum(int length)
	{
		String val = "";
		Random random = new Random();
		for (int i = 0; i < length; i++)
		{
			// 输出字母还是数字
			String charOrNum = random.nextInt(2) % 2 == 0 ? "char" : "num";
			// 字符串
			if ("char".equalsIgnoreCase(charOrNum))
			{

				char ch = (char) (65 + random.nextInt(26));
				while (ch == 'O' || ch == 'I')
				{
					ch = (char) (65 + random.nextInt(26));
				}
				val += ch;
			} else if ("num".equalsIgnoreCase(charOrNum))
			{ // 数字
				int c = random.nextInt(10);
				while (c == 0 || c == 1)
				{
					c = random.nextInt(10);
				}
				val += String.valueOf(c);
			}
		}
		return val;
	}
}
